package com.sk.bilibili.model.activity;

import com.sk.api.annotations.Autowired;
import com.sk.bilibili.bean.Appraise;
import com.sk.bilibili.callBack.RequestCallBack;
import com.sk.bilibili.mapper.AppraiseMapper;
import com.sk.bilibili.model.BaseModel;
import com.sk.bilibili.utils.RequestUtils;
import com.sk.bilibili.view.activity.AppraiseActivity;

public class AppraiseModel extends BaseModel<AppraiseActivity> {

    @Autowired
    AppraiseMapper appraiseMapper;

    public void loadAppraise(Integer themId) {
        RequestUtils.process(appraiseMapper.getAppraise(themId),
                appraise -> view.loadAppraiseSuccess(appraise));
    }

    public void addOrUpdate(Appraise appraise) {
        if(appraise.getId()==null){
            RequestUtils.process(appraiseMapper.add(appraise), unused -> view.addSuccess());
        }else {
            RequestUtils.process(appraiseMapper.update(appraise), unused -> view.updateSuccess());
        }
    }

}